package com.wmg.config;

import com.wmg.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry) {
        System.out.println("========拦截=================");
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/user/**")//需要拦截的路径
                 //排除的路径
                .excludePathPatterns("/user")//首页
                .excludePathPatterns("/user/regist")//注册
                .excludePathPatterns("/user/login")//登录
                .excludePathPatterns("/user/captcha");//验证码
    }

}
